package com.library.entity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by mhy on 2018/1/6.
 */
@Entity
@Table(name="evaluate")
public class Evaluate {
    private Integer evaluateId;   //评价记录ID
    private Book book;
    private Staff staff;
    private Float grade;    //分数
    private String date;    //日期
    private String description; //描述
    private Integer praise; //赞数
    private Integer forbidden;  //举报数
    private Borrow borrow;
    private Set<Praise> praises =new HashSet<Praise>();	//借阅单

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    public Integer getEvaluateId() {
        return evaluateId;
    }

    public void setEvaluateId(Integer evaluateId) {
        this.evaluateId = evaluateId;
    }

    public Float getGrade() {
        return grade;
    }

    public void setGrade(Float grade) {
        this.grade = grade;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @ManyToOne(cascade=CascadeType.PERSIST)
    @JoinColumn(name="staffId")
    public Staff getStaff() {
        return staff;
    }
    public void setStaff(Staff staff) {
        this.staff = staff;
    }

    @ManyToOne(cascade=CascadeType.PERSIST)
    @JoinColumn(name="bookId")
    public Book getBook() {
        return book;
    }
    public void setBook(Book book) {
        this.book = book;
    }

    public Integer getPraise() {
        return praise;
    }

    public void setPraise(Integer praise) {
        this.praise = praise;
    }

    public Integer getForbidden() {
        return forbidden;
    }

    public void setForbidden(Integer forbidden) {
        this.forbidden = forbidden;
    }

    @OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
    @JoinColumn(name="evaluateId")
    public Set<Praise> getPraises() {
        return praises;
    }

    public void setPraises(Set<Praise> praises) {
        this.praises = praises;
    }

    @ManyToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "borrowId")
    public Borrow getBorrow() {
        return borrow;
    }

    public void setBorrow(Borrow borrow) {
        this.borrow = borrow;
    }
}
